pp108 : Event Trigger

Event Trigger

This topic describes an event trigger.

Events in WS-AppServer are used to indicate object manipulation operations such as insert, update, or delete. However, it is necessary to identify the specific action that caused an event. For this purpose, an event trigger is used, which provides information on the action that caused an event.

Event triggers can be attached to all the events that are used by WS-AppServer. These triggers are used by the event listeners in WS-AppServer to determine the cause for an event.

The following table lists all the event triggers available in WS-AppServer. The columns show the triggers, while the rows list the corresponding events that are triggered.

During runtime, an event may be initiated by a single event trigger or a combination of event triggers. Irrespective of the number of triggers, you have to develop the code such that the cause for an event is traceable.

Example

Consider the example of
AfterCommit event that is likely to be caused by either Insert, Update, or Delete operation. In such a case, write the logic as shown here:

/**
 *
 * @param event -
 *            event reference used to trace the event source information
 *
 */

            public void onAfterCommit(AfterCommitObjectEvent event) {

                  if (event.triggeredBy(StdTriggers.INSERT_OBJECT)){

                        // source is insert. insert operation has been committed

                        // put you logic here to perform post insert operation

                  }

                  else if (event.triggeredBy(StdTriggers.UPDATE_OBJECT)){

                        // source is update. doing update operation

                        // put you logic here to perform post update operation

                  }

                  else if (event.triggeredBy(StdTriggers.DELETE_OBJECT)){

                        // source is delete. doing delete operation

                        // put you logic here to perform post delete operation

                  }

            }


Related concepts

Event
Event Listener
Event Object

Related reference

Event Listeners in WS-AppServer
Types of Event Listeners